<?php
/**
 * PhpStorm.
 * User: Jay
 * Date: 2018/8/13
 */

namespace ServiceBundle\Document;


use RedUnicorn\Document\Document;

class ResourceDocument extends Document
{
    public function add()
    {
        $this->setGroup('全局服务/资源服务');
        return parent::add();
    }

    public function setUrl($url)
    {
        return parent::setUrl('/service/resource' .$url);
    }

    /**
     * @throws \Exception
     */
    public function resourceAction()
    {
        $this->add()
            ->setTitle('生成二维码')
            ->setUrl('/qrCode')
            ->addParam('site_uri', '待生成的uri', 'string', false, 'not uri','此参数需 urlencode 转义')
            ->setReturnType('image')
            ->generate();

        $this->add()
            ->setTitle('生成图形验证码')
            ->setUrl('/captcha')
            ->addParam('type', '业务类型', 'string', false, 'captcha','根据业务中API说明传参')
            ->setReturnType('image')
            ->generate();

        $this->add()
            ->setTitle('上传文件')
            ->setUrl('/upload')
            ->setMethod('post')
            ->addParam('file_type', '上传文件类型', 'integer', false, 0, '0:图片 1:视频 2:音频 3:文件 4:压缩包 5:表格')
            ->addParam('input_name', '上传文件的字段name', 'string', false, 'request')
            ->addParam('request', '上传文件', 'file', false, null, '此参数名即为input_name的传参')
            ->generate();

        $this->add()
            ->setTitle('生成唯一值')
            ->setUrl('/generateUuid');

    }

}